#ifndef __DEV_ST7789_H__
#define __DEV_ST7789_H__

#include "device_def.h"

#define ST7789_ROTATION 0

#define WHITE         	 0xFFFF
#define BLACK         	 0x0000	  
#define BLUE           	 0x001F  
#define BRED             0XF81F
#define GRED 			 0XFFE0
#define GBLUE			 0X07FF
#define RED           	 0xF800
#define MAGENTA       	 0xF81F
#define GREEN         	 0x07E0
#define CYAN          	 0x7FFF
#define YELLOW        	 0xFFE0
#define BROWN 			 0XBC40
#define BRRED 			 0XFC07
#define GRAY  			 0X8430

// INPUT 设备控制字
enum {
    ST7789_CMD_INIT = 0U,     // 监视输入控制命令
    ST7789_CMD_DRAW_PIXEL,
    ST7789_CMD_FILL_RECT,
    ST7789_CMD_DISP_FLUSH,
};

// st7789像素数据
typedef struct Dev_ST7789_Data 
{
    uint16_t u16XStart;
    uint16_t u16YStart;
    uint16_t u16XEnd;
    uint16_t u16YEnd;
    uint16_t* pu16Color;
}Dev_ST7789_Data_t;

// ST7789结构体
DEVICE_CONTEXT_DECLARE
(
    Dev_ST7789,

    struct {
        
        void (*pfnWriteCS)(uint8_t u8State);
        void (*pfnWriteDC)(uint8_t u8State);
        void (*pfnWriteBL)(uint8_t u8State);
        void (*pfnWriteRST)(uint8_t u8State);
        uint8_t (*pfnSpiTransmit)(uint8_t* pu8Data, uint32_t u32Len);
    },

    struct {
        uint16_t u16Height;       // 屏幕高度
        uint16_t u16Width;        // 屏幕宽度    
        uint8_t* pu8Cache;        // 缓存区大小
        uint32_t u32CacheLen;     // 缓存区长度
    }
);

// ST7789 设备大小
#define DEV_ST7789_SIZE sizeof(Dev_ST7789_t)

#endif /* __DEV_ST7789_H__ */
